<template>
	<view :style="{
		height: hHeight+'rpx',
		background: hBg
	}"></view>
	<view class="container">
		<slot></slot>
	</view>
	<view class="footer">
		<slot name="footer"></slot>
	</view>

	<view class="tips">
		<view class="icon">
			<uni-icons type="info" size="18" color="#f30"></uni-icons>
		</view>
		<view class="text">
			{{explain}}
		</view>
	</view>
</template>
<script setup>
	import {
		ref,
		onMounted
	} from "vue"
	import cache from "@/util/cache.js"
	defineProps({
		hHeight: {
			type: Number,
			default: 0
		},
		hBg: {
			type: String,
			default: "#3d7eff"
		}
	})
	let explain = ref("")
	onMounted(() => {
		//判断推广数据。
		let pages = getCurrentPages();
		let currentPage = pages[pages.length - 1];
		let options = currentPage.options;
		if (options['?promo']) {
			uni.setStorage({
				key: "Promo",
				data: options['?promo']
			})
		}
		if (options.promo) {
			uni.setStorage({
				key: "Promo",
				data: options.promo
			})
		}
		
		uni.getStorage({
			key: "BaseData",
			success: res => {
				explain.value = res.data.explain
			},
			fail() {
				getCache()
			}
		})
	})
	
	
	const getCache = () => {
		let interval = setInterval(() => {
			uni.getStorage({
				key: "BaseData",
				success: res => {
					explain.value = res.data.explain
					clearInterval(interval)
				}
			})
		}, 200)
	}
</script>
<style lang="scss" scoped>
	.tips {
		display: flex;
		padding: 20rpx;

		.text {
			font-size: 24rpx;
			color: #999;
			margin-left: 10rpx;
		}

	}
</style>